%% @author author <author@example.com>
%% @copyright YYYY author.

%% @doc Callbacks for the xengine application.

-module(xengine_app).
-author('author <author@example.com>').

-behaviour(application).
-export([start/2,stop/1]).


%% @spec start(_Type, _StartArgs) -> ServerRet
%% @doc application start callback for xengine.
start(_Type, _StartArgs) ->
    xengine_deps:ensure(),
    mnesia:start(),
   crypto:start(),
   ssh:start(),
   ssh:daemon(get_ssh_port(), [{system_dir, get_ssh_dir()},
                               {user_passwords, [{"xengine","xengine"}]}]),
    xengine_sup:start_link().

    

%% @spec stop(_State) -> ServerRet
%% @doc application stop callback for xengine.
stop(_State) ->
    ok.
    
get_ssh_dir()->
	case os:getenv("ssh.dir") of false -> "/home/admin/xengine/.ssh";	Any ->  Any end.    


get_ssh_port()->
	 case os:getenv("ssh.port") of 
	        false -> 8888 ;
	        Any -> 
	            {Port,_} = string:to_integer(Any) ,
	            Port
	 end.   	
